<div class="offcanvas-header">
	<h6 class="text-white">
		<i class="bi bi-grid"></i>商品库存分布：#(goodsInfo.name)
	</h6>
	<i class="bi bi-x-square-fill" style="font-size: 1.5rem; color: #ffffff; cursor: pointer;" data-bs-dismiss="offcanvas" aria-label="Close"></i>
</div>
#set(thirdGoodsSpec = goodsInfo.thirdGoodsSpec)
#set(secondGoodsSpec = goodsInfo.secondGoodsSpec)
#set(firstGoodsSpec = goodsInfo.firstGoodsSpec)
#set(thirdSpecValueList = thirdGoodsSpec.specValueList??)
#set(secondSpecValueList = secondGoodsSpec.specValueList??)
#set(firstSpecValueList = firstGoodsSpec.specValueList??)
		
<div class="offcanvas-body">
	<div class="alert alert-warning" role="alert">
	<span class="me-3"><i class="bi bi-shield-exclamation"></i> 库存预警说明：</span>
	<span class="me-3"><i class="bi bi-circle-fill text-success"></i>绿色：库存正常</span>
	<span class="me-3"><i class="bi bi-circle-fill text-warning"></i>黄色：低于安全库存</span>
	<span class="me-3"><i class="bi bi-circle-fill text-danger"></i>红色：低于最低库存</span>
	<span class="me-3"><i class="bi bi-circle-fill text-primary"></i>蓝色：高于最高库存</span>
	</div>
	<table class="table table-hover table-bordered bg-white">
		<thead>
			<tr class="table-header text-center align-items-center">
				#for(x : goodsInfo.goodsSpecRefList) 
				#set(goodsSpec = x.goodsSpec)
				<th class="align-middle">#(goodsSpec.name??)</th> 
				#end
				<th class="align-middle">单位</th>
				<th>总库存</th>
				<th>已订库存</th>
				<th>可用库存</th>
			</tr>
		</thead>
		<tbody class="table-row">
		
		#if(thirdGoodsSpec)
		#set(allCount = firstSpecValueList.size()*thirdSpecValueList.size()*secondSpecValueList.size())
		#set(firstCount = thirdSpecValueList.size()*secondSpecValueList.size())
		#for(first : firstSpecValueList)
		
		#set(secondCount = thirdSpecValueList.size())
		#for(second : secondSpecValueList)
		
		#for(third : thirdSpecValueList)
		
		<tr>
			#if(for.outer.first && for.first)
			<td rowspan="#(firstCount)">#(first.option_value)</td>
			#end
			#if(for.first)
			<td rowspan="#(secondCount)">#(second.option_value)</td>
			#end
			<td>#(third.option_value)</td>
			<td>#(stockUnit.name)</td>
			#set(goodsStock = goodsInfo.getGoodsStock(firstGoodsSpec.goods_spec_id,first.id,secondGoodsSpec.goods_spec_id,second.id,thirdGoodsSpec.goods_spec_id,third.id,stockUnit.id))
			#if(goodsStock)
			#if(goodsStock.warn_type == StockWarnTypeEnum.ok.value) 
			<td><span class="fw-bold text-success"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-success"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-success"> #number(goodsStock.availableStock, "#.####")</span></td>
			#elseif(goodsStock.warn_type == StockWarnTypeEnum.lowest.value) 
			<td><span class="fw-bold text-danger"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-danger"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-danger"> #number(goodsStock.availableStock, "#.####")</span></td>
			
			#elseif(goodsStock.warn_type == StockWarnTypeEnum.lowsafe.value)
			<td><span class="fw-bold text-warning"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-warning"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-warning"> #number(goodsStock.availableStock, "#.####")</span></td>
			
			#elseif(goodsStock.warn_type == StockWarnTypeEnum.highest.value)
			<td><span class="fw-bold text-primary"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-primary"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-primary"> #number(goodsStock.availableStock, "#.####")</span></td>
			#end 
			#else
			<td></td><td></td><td></td>
			#end 			
		</tr>
		#end
		#end
		#end
		
		#elseif(secondGoodsSpec)
		
		#set(allCount = firstSpecValueList.size()*secondSpecValueList.size())
		#set(firstCount = secondSpecValueList.size())
		#for(first : firstSpecValueList)
		
		#for(second : secondSpecValueList)
		
		<tr>
			#if(for.first)
			<td rowspan="#(firstCount)">#(first.option_value)</td>
			#end
			<td>#(second.option_value)</td>
			<td>#(stockUnit.name)</td>
			#set(goodsStock = goodsInfo.getGoodsStock(firstGoodsSpec.goods_spec_id,first.id,secondGoodsSpec.goods_spec_id,second.id,0,0,stockUnit.id))
			#if(goodsStock)
			#if(goodsStock.warn_type == StockWarnTypeEnum.ok.value) 
			<td><span class="fw-bold text-success"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-success"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-success"> #number(goodsStock.availableStock, "#.####")</span></td>
			#elseif(goodsStock.warn_type == StockWarnTypeEnum.lowest.value) 
			<td><span class="fw-bold text-danger"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-danger"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-danger"> #number(goodsStock.availableStock, "#.####")</span></td>
			
			#elseif(goodsStock.warn_type == StockWarnTypeEnum.lowsafe.value)
			<td><span class="fw-bold text-warning"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-warning"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-warning"> #number(goodsStock.availableStock, "#.####")</span></td>
			
			#elseif(goodsStock.warn_type == StockWarnTypeEnum.highest.value)
			<td><span class="fw-bold text-primary"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-primary"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-primary"> #number(goodsStock.availableStock, "#.####")</span></td>
			#end 
			#else
			<td></td><td></td><td></td>
			#end 
			
		</tr>
		#end
		#end
		
		
		#elseif(firstGoodsSpec)
		
		#set(allCount = firstSpecValueList.size())
		#for(first : firstSpecValueList)
		
		<tr>
			<td>#(first.option_value)</td>
			<td>#(stockUnit.name)</td>
			#set(goodsStock = goodsInfo.getGoodsStock(firstGoodsSpec.goods_spec_id,first.id,0,0,0,0,stockUnit.id))
			#if(goodsStock)
			#if(goodsStock.warn_type == StockWarnTypeEnum.ok.value) 
			<td><span class="fw-bold text-success"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-success"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-success"> #number(goodsStock.availableStock, "#.####")</span></td>
			#elseif(goodsStock.warn_type == StockWarnTypeEnum.lowest.value) 
			<td><span class="fw-bold text-danger"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-danger"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-danger"> #number(goodsStock.availableStock, "#.####")</span></td>
			
			#elseif(goodsStock.warn_type == StockWarnTypeEnum.lowsafe.value)
			<td><span class="fw-bold text-warning"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-warning"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-warning"> #number(goodsStock.availableStock, "#.####")</span></td>
			
			#elseif(goodsStock.warn_type == StockWarnTypeEnum.highest.value)
			<td><span class="fw-bold text-primary"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-primary"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-primary"> #number(goodsStock.availableStock, "#.####")</span></td>
			#end 
			#else
			<td></td><td></td><td></td>
			#end 
		</tr>
		#end
		
		#else
		<tr>
			<td>#(stockUnit.name)</td>
			#set(goodsStock = goodsInfo.getGoodsStock(0,0,0,0,0,0,stockUnit.id))
			#if(goodsStock)
			#if(goodsStock.warn_type == StockWarnTypeEnum.ok.value) 
			<td><span class="fw-bold text-success"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-success"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-success"> #number(goodsStock.availableStock, "#.####")</span></td>
			#elseif(goodsStock.warn_type == StockWarnTypeEnum.lowest.value) 
			<td><span class="fw-bold text-danger"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-danger"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-danger"> #number(goodsStock.availableStock, "#.####")</span></td>
			
			#elseif(goodsStock.warn_type == StockWarnTypeEnum.lowsafe.value)
			<td><span class="fw-bold text-warning"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-warning"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-warning"> #number(goodsStock.availableStock, "#.####")</span></td>
			
			#elseif(goodsStock.warn_type == StockWarnTypeEnum.highest.value)
			<td><span class="fw-bold text-primary"> #number(goodsStock.stock, "#.####")</span></td>
			<td><span class="fw-bold text-primary"> #number(goodsStock.reserve_stock, "#.####")</span></td>
			<td><span class="fw-bold text-primary"> #number(goodsStock.availableStock, "#.####")</span></td>
			#end 
			#else
			<td></td><td></td><td></td>
			#end 
		</tr>
		#end
		</tbody>
	</table>
</div>